package com.itlong.cloud.commons.wechat;


import com.itlong.cloud.paymenthub.IWeChatPayServiceClient;
import org.slf4j.Logger;import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.RestController;

/**
 * <desc>
 *      微信下载账单对账定时任务
 * </desc>
 *
 * @createDate 2018/08/18
 */
@EnableScheduling // 启用定时任务
@RestController
public class WechatBillTimedTask {
    private static Logger LOG = LoggerFactory.getLogger(WechatBillTimedTask.class);

    @Autowired
    IWeChatPayServiceClient iWeChatPayServiceClient;

    /**
     * <desc>
     *      定时任务获取前一天的微信对账单
     * </desc>
     *
     * @throws Exception
     * @author Juguang.S
     * @createDate 2018/09/03
     */
    @Scheduled(cron = "0 0 10 * * ?") // 每天十点执行
    //@Scheduled(cron = "0 */5 * * * ?") // 每天十点执行
    public void statisticsForDay() throws Exception {
        try {
//            LOG.info("【定时任务】定时获取前一天的微信对账单开始执行定时任务");
            iWeChatPayServiceClient.downloadWechatBill();
//            LOG.info("【定时任务】定时获取前一天的微信对账单成功");
        } catch (Exception e) {
            LOG.error("【定时任务】定时获取前一天的微信对账单失败");
            throw e;
        }
    }
}